<template>
<div class="layerRtb layerRtb-threecolumn">
    <three-title :title="{name:'消息推送'}" ></three-title>
    <div class="layerRtb-scroll thinScroll" v-scrollHeight = "10">
        <div class="clearfix mb10 lh22">
            <span class="width70 fl">消息类型：</span>
            <div class="messagestuis-yc" id="messagestype">
                <span  :class="subIndex==1? 'acurrent':''"   @click="menster(1)" class="fl messagestypelink mr10">活动通知</span>
                 <span  :class="subIndex==2? 'acurrent':''"   @click="menster(2)" class="fl messagestypelink mr10">时间通知</span>
                  <span  :class="subIndex==3? 'acurrent':''" @click="menster(3)" class="fl messagestypelink mr10">业务通知</span>
                   <span  :class="subIndex==4? 'acurrent':''"  @click="menster(4)" class="fl messagestypelink mr10">红包通知</span>
                    <span  :class="subIndex==5? 'acurrent':''"   @click="menster(5)" class="fl messagestypelink mr10">其他通知</span>
            </div>
        </div>
        <div class="clearfix mb10">
            <span class="width70 fl">推送方式：</span>
            <div class="messagestuis-yc">
                <label class="fl uiRadio12 mr10">
                    <input type="checkbox" class="uiRadio12-input" name="ts_show_type" value="1">消息弹框
                </label>
            </div>
        </div>
        <div class="clearfix mb10 lh22">
            <span class="width70 fl">选择人员：</span>
            <div class="messagestuis-yc">当前已选 <strong class="fz16" id="ShowTuisongCount">{{ressment}}</strong>人</div>
        </div>
        <h2 class="h2-title mb10">内容编辑</h2>
        <div class="clearfix mb10">
            <input type="text" v-model="AlertTitle" placeholder="请输入消息标题" class="col-md-12" id="ts_msg_title">
        </div>
        <div class="clearfix mb10">
            <textarea class="col-md-12" rows="3" id="ts_msg_content" v-model="AlertText"></textarea>
        </div>
        <div class="tx-center">
            <input type="button" value="发送" class="uiBtn-blue uiBtn-normal" @click="mensererr()" id="saveAPPTuiSong">
        </div>
    </div>
    <!-- <div class="layerRtb-footer">
        <div class="analyItem">
            <p class="analyItemTit tx-center">综合</p>
            <div class="analyItemCon">
                  <div class="tx-center pt10 pb10">

                  </div>
            </div>
        </div>
    </div> -->
</div>
</template>
<script>
import {mapGetters, mapMutations} from 'vuex'
import {SendPost} from '../Resources/Api/index'
export default {
    data () {
        return {
            ressment: '',
            AlertText: '',
            AlertTitle: '',
            subIndex: 1,
            premenwe: [{pressName: '活动通知', id: '1'}, {pressName: '事件通知', id: '2'}, {pressName: '业务通知', id: '3'}, {pressName: '红包通知', id: '4'}, {pressName: '其他通知', id: '5'}]
        }
    },
    computed: {
        ...mapGetters(['leftInfo', 'updatePlate', 'rx', 'twoleftInfo', 'userInfo'])
    },
    beforeRouteLeave (to, from, next) {
        this.settwoUpdatePlate(0)
        next()
    },
    created () {
    },
    methods: {
        menster (index) {
            this.subIndex = index
        },

        mensererr () {
            for (let index = 0; index < this.twoleftInfo.length; index++) {
                var mensfb = this.twoleftInfo[index]
                this.SendPost(mensfb)
            }
            this.InitiatorCard = this.userInfo.UserName
            this.InitiatorName = this.userInfo.UserNo
        },

        ...mapMutations({
            settwoUpdatePlate: 'SET_TWOUPDATE_PLATE'
        }),
        SendPost (CardNo) {
            SendPost({
                AlertText: this.AlertText,
                AlertTitle: this.AlertTitle,
                Type: 0,
                Group: this.subIndex,
                IsApp: 5,
                CardNo: CardNo,
                IsApnsProduction: true,
                InitiatorCard: this.InitiatorCard,
                InitiatorName: this.InitiatorName
            }).then(res => {

            }).catch(err => {
                console.log(err)
            })
        }

    },
    watch: {
        twoleftInfo () {
            this.ressment = this.twoleftInfo.length
        },
        $route () {
            this.settwoUpdatePlate(0)
        }
    }
}
</script>
<style>
.acurrent {
    width: 60px;
    border-radius: 3px;
    background: #0099ff;
    color: #fff;
    text-align: center;
}
</style>
